import javax.swing.JOptionPane;

public class Interfaz extends javax.swing.JFrame {

    int contincrementa=0;
    int contdecremento=0;
    int reset=0;
    int acumulador1=0;
    int acumulador2=0;
    String cadena="";


    public Interfaz() {
        initComponents();
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Incrementa = new javax.swing.JButton();
        Decremento = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        Txt_Acumulador = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        Txt_Estado = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        btn_Primos = new javax.swing.JButton();
        btn_Pares = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Incrementa.setText("Incrementar");
        Incrementa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                IncrementaActionPerformed(evt);
            }
        });

        Decremento.setText("Decrementar");
        Decremento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DecrementoActionPerformed(evt);
            }
        });

        Reset.setText("Reset");
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });

        Txt_Acumulador.setEditable(false);
        Txt_Acumulador.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        Txt_Acumulador.setText("0");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel1.setText("Sistema de Asignación de Citas Automatizadas.");

        Txt_Estado.setEditable(false);
        Txt_Estado.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        Txt_Estado.setText("0");

        jLabel2.setText("Estado");

        jLabel3.setText("Número");

        btn_Primos.setText("Numeros Primos");
        btn_Primos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_PrimosActionPerformed(evt);
            }
        });

        btn_Pares.setText("Números Pares");
        btn_Pares.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ParesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(jLabel1)
                .addContainerGap(14, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(101, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Txt_Estado, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(140, 140, 140)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(Txt_Acumulador, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(75, 75, 75))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(127, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(Incrementa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btn_Pares, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(42, 42, 42)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btn_Primos)
                    .addComponent(Decremento, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE))
                .addContainerGap(97, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(220, Short.MAX_VALUE)
                .addComponent(Reset)
                .addGap(199, 199, 199))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Txt_Estado, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Txt_Acumulador, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Incrementa)
                    .addComponent(Decremento))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btn_Pares)
                    .addComponent(btn_Primos))
                .addGap(18, 18, 18)
                .addComponent(Reset)
                .addContainerGap(49, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void IncrementaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncrementaActionPerformed

        Txt_Estado.setText("1");
             int num =0;
             num = Integer.parseInt( Txt_Acumulador.getText());
             if(num==10){
              JOptionPane.showMessageDialog(null, "Número igual a 10","Atención",JOptionPane.INFORMATION_MESSAGE);
             }
             else
             {
            num++;
            Txt_Acumulador.setText(Integer.toString(num));
             }

    }//GEN-LAST:event_IncrementaActionPerformed

    private void DecrementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DecrementoActionPerformed
        // TODO add your handling code here:
        Txt_Estado.setText("2");
       int num =0;
             num = Integer.parseInt( Txt_Acumulador.getText());

             if(num==0){
              JOptionPane.showMessageDialog(null, "Número igual a 0","Atención",JOptionPane.INFORMATION_MESSAGE);
             }
             else
             {
            num--;
            Txt_Acumulador.setText(Integer.toString(num));
             }
    }//GEN-LAST:event_DecrementoActionPerformed

    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetActionPerformed
        // TODO add your handling code here:

        Txt_Acumulador.setText("0");
        Txt_Estado.setText("0");

    }//GEN-LAST:event_ResetActionPerformed

    private void btn_ParesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ParesActionPerformed

        Txt_Estado.setText("3");

        int num =0;
        num = Integer.parseInt( Txt_Acumulador.getText());
        num++;
        if(num%2!=0)
        {
            num+=1;
        }

        if(num==12){
          JOptionPane.showMessageDialog(null, "Número igual a 10","Atención",JOptionPane.INFORMATION_MESSAGE);
         }
         else
         {
        Txt_Acumulador.setText(Integer.toString(num));
         }



    }//GEN-LAST:event_btn_ParesActionPerformed

    private void btn_PrimosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_PrimosActionPerformed

        Txt_Estado.setText("4");
        int num =0;
        int xxx=0;
        num = Integer.parseInt( Txt_Acumulador.getText());
        num++;
     while(xxx==0)
        {
        if(num==2)
        {
            Txt_Acumulador.setText(Integer.toString(num));
            xxx=1;
        }
        else
        {
            if(num==3)
            {
                Txt_Acumulador.setText(Integer.toString(num));
                xxx=1;
            }
            else
            {
                if(num==5)
                {
                    Txt_Acumulador.setText(Integer.toString(num));
                    xxx=1;
                }
                else
                {
                    if(num==7)
                    {
                        Txt_Acumulador.setText(Integer.toString(num));
                        xxx=1;
                    }
                    else
                    {
                        num++;
                        
                    }
                }
            }
        }
        if(num==10){
          JOptionPane.showMessageDialog(null, "Número al Máximo","Atención",JOptionPane.INFORMATION_MESSAGE);
         xxx=1;}
         
    }
    }//GEN-LAST:event_btn_PrimosActionPerformed

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Interfaz().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Decremento;
    private javax.swing.JButton Incrementa;
    private javax.swing.JButton Reset;
    private javax.swing.JTextField Txt_Acumulador;
    private javax.swing.JTextField Txt_Estado;
    private javax.swing.JButton btn_Pares;
    private javax.swing.JButton btn_Primos;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration//GEN-END:variables

}
